import requests
from lxml import etree

if __name__ == '__main__':
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
    }
    url = "https://www.aqistudy.cn/historydata"
    page_text = requests.get(url=url, headers=headers).text

    tree = etree.HTML(page_text)
    all_city_list =[]
    hot_li_list = tree.xpath("//div[@class='bottom']//li")
    #
    a_list = tree.xpath("//div[@class='bottom']/ul/li/a | //div[@class='bottom']/ul/div[2]/li/a")
    for li in hot_li_list:
        all_city_list.append(li.xpath("./a/text()")[0])
    print(all_city_list)
    print(len(all_city_list))
